package com.ctshk.rpc.custom.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.custom.base.CustomBaseMapper;
import com.ctshk.rpc.custom.dto.trip.TripScheduleItineraryDayDTO;
import com.ctshk.rpc.custom.entity.CustomizedTripScheduleItineraryDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 天行程 Mapper 接口
 * </p>
 *
 * @author xuhui
 * @since 1/22/2021
 */
public interface CustomizedTripScheduleItineraryDayMapper extends CustomBaseMapper<CustomizedTripScheduleItineraryDay> {
    /**
     * 查询每日行程列表
     * @param itineraryId
     * @return
     */
    @Select("SELECT `day`,title,traffic_json AS trafficJsonStr,traffic_remark,food_json AS foodJsonStr,food_remark,hotel_json AS hotelJsonStr,hotel_remark,scenic_json AS scenicJsonStr,day_remark \n" +
            "FROM t_customized_trip_schedule_itinerary_day\n" +
            "WHERE itinerary_id = #{itinerary_id} AND is_deleted = 0 ORDER BY `day` ASC")
    List<TripScheduleItineraryDayDTO> queryList(@Param("itinerary_id") Long itineraryId);

    /**
     * 清空行程每日介绍
     * @param ItineraryId
     * @param userId
     * @return
     */
    @Update("UPDATE t_customized_trip_schedule_itinerary_day\n" +
            "SET is_deleted = 1,modified_id = #{modified_id}\n" +
            "WHERE itinerary_id = #{itinerary_id} AND is_deleted = 0")
    Integer clearByItinerary(@Param("itinerary_id") Long ItineraryId, @Param("modified_id") Long userId);
}
